<a href="<?php echo( base_url() ); ?>cmb/member_reports/download_balavihar_my_attendance_report/<?php echo( $urlKey ); ?>/" target="_self">Download Data</a>
<?php
	Includes::IncludeFile( Includes::$FORM );
	Includes::IncludeFile( Includes::$SPACER );
	
	$curdatetime = time();	
	$curdate = date('l, F jS, Y', $curdatetime);
	$numteachergroups = count($tginfoarr);
	
	Form::OpenFormItemSummary('Date:', 75);
		echo( form_label($curdate, 'numrecs', 'style="width: 50px;" ') );
	Form::CloseFormItem();

	$curtime = date('h:i:s A', $curdatetime);
	Form::OpenFormItemSummary('Time:', 75);
		echo( form_label($curtime, 'numrecs', 'style="width: 50px;" ') );
	Form::CloseFormItem();

	Form::OpenFormItemSummary('School Year:', 75);
		echo( form_label($year.'-'.($year+1), 'numrecs', 'style="width: 20px;" ') );
	Form::CloseFormItem();
	echo('<hr style="width:50%; size:10; color:#0000FF;" align="left" />');	
	
	if ($numteachergroups > 0)
	{
		$numweeks = count($tginfoarr[0]);
		
		for($itg = 0; $itg < $numteachergroups; $itg++)
		{
			$bvattinfo = $tginfoarr[$itg];
			$numstudents = count($bvattinfo[0]);
			$searchcriteria = $srchinfoarr[$itg];
		
			Form::OpenFormItemSummary('Center:', 260);
				echo( form_label($searchcriteria['centername'], 'numrecs', 'style="width: 20px;" ') );
			Form::CloseFormItem();
			
			Form::OpenFormItemSummary('Session:', 260);
				echo( form_label($searchcriteria['session'], 'numrecs', 'style="width: 20px;" ') );
			Form::CloseFormItem();
			
			Form::OpenFormItemSummary('Grade:', 260);
				echo( form_label($searchcriteria['gradename'], 'numrecs', 'style="width: 20px;" ') );
			Form::CloseFormItem();
			
			Form::OpenFormItemSummary('Number of students:', 260);
				echo( form_label($numstudents, 'numrecs', 'style="width: 20px;" ') );
			Form::CloseFormItem();
				
			$i = 1;
			$teachers = $teachersarr[$itg];
			foreach ($teachers as $tvrec)
			{
				Form::OpenFormItemSummary('Teacher'.$i.':', 260);
					echo( form_label($tvrec, 'numrecs', 'style="width: 20px;" ') );
				Form::CloseFormItem();
				
				$i ++;						
			}
		
			echo('<hr style="width:50%; size:10; color:#0000FF;" align="left" />');
			
			Spacer::Render(0, 3);	
		
			echo('<table border="1">');
		
			if ($numstudents > 0)
			{
				echo('<th><center><b>&nbspStudent&nbspName&nbsp</b></center></th>');
				
				for($iw = 0; $iw < $curweekseq; $iw++)
				{
					$bvwkrec = $bvattinfo[$iw];
					$bvclass = $bvwkrec[0];
					echo('<th><center><b>&nbsp'.$bvclass[1].'&nbsp</b></center></th>');;
				}			
		
				for($ic = 0; $ic < $numstudents; $ic++)
				{
					if ($ic % 2 != 0)
					{
						$rowColor = "#e0ffff";
					}
					else
					{
						$rowColor = "#ffffff";
					}
					
					echo('<tr bgcolor="'.$rowColor.'">');
					$bvwkrec = $bvattinfo[0];
					$bvclass = $bvwkrec[$ic];
					if ($bvclass[6] == "unreg")
						echo('<td><font color="red">&nbsp'.$bvclass[2].'&nbsp'.$bvclass[3].'&nbsp</font></td>');
					else
						echo('<td>&nbsp'.$bvclass[2].'&nbsp'.$bvclass[3].'&nbsp</td>');
					
					for($iw = 0; $iw < $curweekseq; $iw++)
					{
						$bvwkrec = $bvattinfo[$iw];
						$bvclass = $bvwkrec[$ic];
						if ($bvclass[4] == 0)
							$status = "-";
						else				
						{
							if ($bvclass[4] == 1)
								$status = "+";
							else
								$status = "na";
						}
							
						if ($bvclass[6] == "unreg")
							echo('<td><font color="red"><center>'.$status.'</center></font></td>');
						else
							echo('<td><center>'.$status.'</center></td>');
					}
					
					echo('</tr>');
				}
			}
			else
				echo "No students in class";
		
			echo('</table>');
			Spacer::Render(0, 20);
			echo('<hr style="width:50%; size:10; color:#0000FF;" align="left" />');
		}
	}
	else
	 echo "No results returned";
?>